/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.api;

import com.github.lvyanyang.annotation.Authorize;
import com.github.lvyanyang.core.BaseController;
import com.github.lvyanyang.core.BoolResult;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.PageList;
import com.github.lvyanyang.core.XCI;
import com.xci.edu.core.entity.EduStudentPeriodSummary;
import com.xci.edu.core.filter.EduStudentPeriodSummaryFilter;
import com.xci.edu.core.service.EduStudentPeriodSummaryService;
import com.github.lvyanyang.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学员学时汇总接口
 * @author 焦元义 jiaoyuanyi@xci96716.com
 * @since 2020-11-24 15:14:37
 */
@Api(tags = "学员学时汇总接口")
@Authorize
@RestController
@RequestMapping(value = "/api/core/eduStudentPeriodSummary", produces = Const.PROJSON)
public class EduStudentPeriodSummaryApiController extends BaseController {
    /** 学员学时汇总服务 */
    @Resource private EduStudentPeriodSummaryService eduStudentPeriodSummaryService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新建学员学时汇总")
    //@Authorize(code = "core.eduStudentPeriodSummary.insert")
    @PostMapping("/insert")
    public BoolResult insert(@RequestBody EduStudentPeriodSummary entity) {
        return eduStudentPeriodSummaryService.insert(entity);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "修改学员学时汇总")
    //@Authorize(code = "core.eduStudentPeriodSummary.update")
    @PostMapping("/update")
    public BoolResult update(@RequestBody EduStudentPeriodSummary entity) {
        return eduStudentPeriodSummaryService.update(entity);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "修改学员学时汇总状态")
    //@Authorize(code = "core.eduStudentPeriodSummary.updateStatus")
    @PostMapping(value = "/updateStatus")
    public BoolResult updateStatus(@RequestBody IdsStatusBody body) {
        eduStudentPeriodSummaryService.updateStatus(body.getIds(), body.getStatus());
        return BoolResult.success();
    }

//    @ApiOperationSupport(order = 3)
//    @ApiOperation(value = "根据主键字符串删除学员学时汇总")
//    //@Authorize(code = "core.eduStudentPeriodSummary.delete")
//    @PostMapping(value = "/delete")
//    public BoolResult delete(@RequestBody IdsBody body) {
//        return eduStudentPeriodSummaryService.delete(body.getIds());
//    }

    //@ApiOperationSupport(order = 4)
    //@ApiOperation(value = "检查学员学时汇总主键是否存在")
    //@PostMapping(value = "/existById")
    //public BoolResult existById(@RequestBody IdBody body) {
    //    return BoolResult.success(eduStudentPeriodSummaryService.existById(body.getId()));
    //}
    //@ApiOperationSupport(order = 5)
    //@ApiOperation(value = "检查学员学时汇总名称是否存在")
    //@PostMapping(value = "/existByName")
    //public BoolResult existByName(@RequestBody NameExcludeIdBody body) {
    //    return BoolResult.success(eduStudentPeriodSummaryService.existByName(body.getName(), body.getExcludeId()));
    //}
    //@ApiOperationSupport(order = 6)
    //@ApiOperation(value = "检查学员学时汇总编码是否存在")
    //@PostMapping(value = "/existByCode")
    //public BoolResult existByCode(@RequestBody CodeExcludeIdBody body) {
    //    return BoolResult.success(eduStudentPeriodSummaryService.existByCode(body.getCode(), body.getExcludeId()));
    //}

//    @ApiOperationSupport(order = 7)
//    @ApiOperation(value = "根据主键查询单个学员学时汇总")
//    //@Authorize(code = "core.eduStudentPeriodSummary.select")
//    @PostMapping("/selectById")
//    public BoolResult<EduStudentPeriodSummary> selectById(@RequestBody IdBody body) {
//        return BoolResult.success(eduStudentPeriodSummaryService.selectById(body.getId()));
//    }

    //@ApiOperationSupport(order = 8)
    //@ApiOperation(value = "根据编码查询单个学员学时汇总")
    ////@Authorize(code = "core.eduStudentPeriodSummary.select")
    //@PostMapping("/selectByCode")
    //public BoolResult<EduStudentPeriodSummary> selectByCode(@RequestBody CodeBody body) {
    //    return BoolResult.success(eduStudentPeriodSummaryService.selectByCode(body.getCode()));
    //}

    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "查询学员学时汇总分页列表")
    //@Authorize(code = "core.eduStudentPeriodSummary.select")
    @PostMapping("/selectPageList")
    public BoolResult<PageList<EduStudentPeriodSummary>> selectPageList(@RequestBody EduStudentPeriodSummaryFilter filter) {
        return BoolResult.success(eduStudentPeriodSummaryService.selectPageList(filter));
    }

    @ApiOperationSupport(order = 10, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "查询学员学时汇总列表")
    //@Authorize(code = "core.eduStudentPeriodSummary.select")
    @PostMapping("/selectList")
    public BoolResult<List<EduStudentPeriodSummary>> selectList(@RequestBody EduStudentPeriodSummaryFilter filter) {
        return BoolResult.success(eduStudentPeriodSummaryService.selectList(filter));
    }

    @ApiOperationSupport(order = 13, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "学员学时汇总")
    //@Authorize(code = "core.eduStudentPeriodSummary.select")
    @PostMapping("/selectPeriodToStudent")
    public BoolResult<List<EduStudentPeriodSummary>> selectPeriodToStudent(@RequestBody EduStudentPeriodSummaryFilter filter) {
        return BoolResult.success(eduStudentPeriodSummaryService.selectPeriodToStudent(filter));
    }

    @ApiOperationSupport(order = 11, ignoreParameters = {Const.IPI, Const.IPS, Const.IPSN, Const.IPSD})
    @ApiOperation(value = "导出学员学时汇总列表")
    //@Authorize(code = "core.eduStudentPeriodSummary.export")
    @PostMapping(value = "/export", produces = {Const.PROOCTET, Const.PROJSON})
    public void export(@RequestBody EduStudentPeriodSummaryFilter filter) {
        XCI.exportExcel(eduStudentPeriodSummaryService.selectList(filter), EduStudentPeriodSummary.class, "学员学时汇总列表");
    }

    //@ApiOperationSupport(order = 12)
    //@ApiOperation(value = "获取学员学时汇总导出字段")
    //@PostMapping(value = "/exportNames")
    //public BoolResult<List<String>> exportNames() {
    //    return BoolResult.success(XCI.getExcelFiledNames(EduStudentPeriodSummary.class));
    //}
}
